<?php use_helper('yougoDate', 'Date') ?>

<tr class="months years">
    <?php if ($admin): ?><th class="empty"></th><?php endif ?>
    <?php for ($i = 0; $i < count($calendar); $i++): ?>
        <th colspan="<?php echo get_days_remaining_in_month($calendar, $i) + 1 ?>">
            <?php echo format_date($calendar[$i]->getTimestamp(), 'MMMM y') ?>
        </th>
        <?php $i += get_days_remaining_in_month($calendar, $i) ?>
    <?php endfor ?>
</tr>
<tr class="weeks">
    <?php if ($admin): ?><th class="empty"></th><?php endif ?>
    <?php for ($i = 0; $i < count($calendar); $i++): ?>
        <th colspan="<?php echo get_days_remaining_in_week($calendar, $i) + 1 ?>">
            S<?php echo format_date($calendar[$i]->getTimestamp(), 'w') ?>
        </th>
        <?php $i += get_days_remaining_in_week($calendar, $i) ?>
    <?php endfor ?>
</tr>
<tr class="days letter">
    <?php if ($admin): ?><th class="empty"></th><?php endif ?>
    <?php for ($i = 0; $i < count($calendar); $i++): ?>
        <th><?php echo format_date($calendar[$i]->getTimestamp(), 'EE') ?></th>
    <?php endfor ?>
</tr>
<tr class="days number">
    <?php if ($admin): ?><th class="empty"></th><?php endif ?>
    <?php for ($i = 0; $i < count($calendar); $i++): ?>
        <th><?php echo format_date($calendar[$i]->getTimestamp(), 'dd') ?></th>
    <?php endfor ?>
</tr>
